package com.example.system.controller;

import com.example.common.Result;
import com.example.system.entity.Druginfo;
import com.example.system.service.IDruginfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2023-04-13
 */
@RestController
@RequestMapping("/system/druginfo")
@CrossOrigin
public class DruginfoController {

    @Autowired
    private IDruginfoService druginfoService;

    @GetMapping("/all")

    public Result<List<Druginfo>> getallDrug(){
        List<Druginfo> list = druginfoService.list();
        return new Result<>(200,"请求成功",list);
    }
    @GetMapping("{id}")
    public Result<Druginfo> getOneDrug(@PathVariable("id") Integer id){
        Druginfo drug = druginfoService.getById(id);
        System.out.println(drug);
        return new Result<>(200,"请求成功",drug);
    }

}
